import time

def bubble_sort(a):
    for i in range(len(a) - 1):
        swapped = False
        for j in range(len(a) - i - 1):
            if a[j] > a[j + 1]:
                a[j], a[j + 1] = a[j + 1], a[j]
                swapped = True
        if not swapped:
            break

f = ['m1_sorted.txt', 'm2_reverse.txt', 'm3_shuffle.txt']
for file in f:
    with open(file, 'r') as f:
        b = [int(line) for line in f]
    s_t = time.time()
    bubble_sort(b)
    e_t = time.time()
    d = int((e_t - s_t) * 1000)
    file = file.split('.')[0]
    print(f"{file} {d} milliseconds")
